import Vue from "vue"
import router from "../router"
import store from "../store"

export default {
    mustBeLogin() {
        let token = localStorage.getItem("token");
        if (!token) {
            Vue.prototype.$toast("请先登录!");
            setTimeout(() => {
                // isGoBack 改成true
                // 调用muations中的chanisGoBack方法,传一个参数true
                store["_mutations"]["isGoBack/chanIsGoBack"][0](true);
                router.push("/user");
            }, 1000);
            return false;
        }
        return true;
    }
}